-
Notifications
You must be signed in to change notification settings - Fork 246
Replace match_token!
proc macro with tag!
macro_rules macro
#640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
762a26e
to
1ead52f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea!
Having to write tag_token!(tag @ ["html"] | [/"body"])
is odd though.
Can't it be tag_token!(tag @ <html> | </body>)
if the macro match arm is changed from (__inner:[/$tag:tt])
to something like (__inner:</$tag:ident>)
?
You could convert the ident
to a tt
using the stringify
macro and that would remove the need for quotes at the macro invocation site.
Signed-off-by: Nico Burns <[email protected]>
1ead52f
to
d22aff7
Compare
@simonwuelker I managed to get <> instead of [] working. I also got bare <> and </> working. But I couldn't get rid of the quotes around the tag name. The problem is order of evaluation. You can't do I think it could be made to work if we either made |
Signed-off-by: Nico Burns <[email protected]>
d22aff7
to
5c39655
Compare
Signed-off-by: Nico Burns <[email protected]>
05c70a9
to
a8858a4
Compare
Ok, I've made this work. We can't use I've updated the example in PR description with the new syntax. |
15c2fd8
to
af5a120
Compare
Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
af5a120
to
6e431bf
Compare
@simonwuelker @jdm (no urgency but:) This is now fully working and is in a position where it could be implemeted. It would just be a case of going through the The main difference are:
Thoughts? P.S. Minor note on syntax: it would also be possible to write |
Personally I would prefer to implement functions for the "else" cases (like Other than that, this looks great! I'm all for less magic and less proc macros, even if it ends up being slightly more verbose.
Not a big difference but I prefer to keep the macro invocation as small as possible(the current version).
Yeah adding proper spec comments is something else that I eventually want to come around too... But it's a dull task (: |
Same! I love removing syntax unique to this crate. |
…BeforeHtml Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
match_token
proc macro with macro_rules!
macrosmatch_token!
proc macro with tag!
macro_rules macro
Signed-off-by: Nico Burns <[email protected]>
5aac3e6
to
b0b1b54
Compare
Signed-off-by: Nico Burns <[email protected]>
Ok, I've rolled this out to the entire I haven't added proper spec comments, but I have added links to the spec for each
|
Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
Replaces the
match_token!
procedural macro to be replaced with a series of simplertag!
macro_rules macros combined with a regular rustmatch
expression.Requires a new string-cache-codegen release:
The following code block:
would be replaced with: